﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Security;
using MyMainSite2.Data.Repositories;

namespace MyMainSite2.Library.MVC.Providers
{
	public class AdminRoleProvider : RoleProvider
	{
		#region Public Methods

		public override void AddUsersToRoles(string[] usernames, string[] roleNames)
		{
			throw new NotImplementedException();
		}

		public override string ApplicationName
		{
			get
			{
				throw new NotImplementedException();
			}
			set
			{
				throw new NotImplementedException();
			}
		}

		public override void CreateRole(string roleName)
		{
			throw new NotImplementedException();
		}

		public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
		{
			throw new NotImplementedException();
		}

		public override string[] FindUsersInRole(string roleName, string usernameToMatch)
		{
			throw new NotImplementedException();
		}

		public override string[] GetAllRoles()
		{
			throw new NotImplementedException();
		}

		public override string[] GetRolesForUser(string userName)
		{
			if (String.IsNullOrWhiteSpace(userName))
				throw new ArgumentException("userName");

			var roles = AdminRoleRepositoryFactory.Repository.GetRolesForUser(userName);

			var names = from n in roles
						select n.Name;

			return names.ToArray();
		}

		public override string[] GetUsersInRole(string roleName)
		{
			throw new NotImplementedException();
		}

		public override bool IsUserInRole(string userName, string roleName)
		{
			if (String.IsNullOrWhiteSpace(userName))
				throw new ArgumentException("userName");

			if (String.IsNullOrWhiteSpace(roleName))
				throw new ArgumentException("roleName");

			return AdminRoleRepositoryFactory.Repository.IsUserInRole(userName, roleName);
		}

		public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
		{
			throw new NotImplementedException();
		}

		public override bool RoleExists(string roleName)
		{
			throw new NotImplementedException();
		}

		#endregion
	}
}
